package com.superiron.scaffold.core.service.executor;

import lombok.Getter;
import org.springframework.web.context.request.async.DeferredResult;

import java.util.concurrent.Callable;

/**
 * @author ：yzg
 * @date ：Created in 2022/6/10 17:19
 * @description：
 * @modified By：
 * @version: $
 */
public abstract class MyCallable<V> implements Callable<V> {
	
	
	@Getter
	private DeferredResult deferredResult ;
	
	
	public MyCallable(DeferredResult deferredResult){
		this.deferredResult = deferredResult ;
	}
	
	@Override
	public V call() throws Exception {
		befordCall();
		V v = doCall();
		afterCall();
		return v ;
	}
	
	/**
	 * 任务执行
	 * @author yzg
	 * @date 2017 -11-13 10:55:59
	 */
	public abstract V doCall() ;
	
	/**
	 * 执行之前
	 * @author yzg
	 * @date 2017 -11-13 10:55:59
	 */
	public void befordCall(){
		
	}
	
	/**
	 * 执行之后
	 * @author yzg
	 * @date 2017 -11-13 10:55:59
	 */
	public void afterCall(){
		
	}
}

